#pragma once
#include <sample_comm.h>
#include "ctx.h"

void init_venc_cfg(chnInputCfg *pIc);
int init_venc(SERVICE_CTX_ENTITY *ent);
void deinit_venc(SERVICE_CTX_ENTITY *ent);

#define DEFAULT_BS_MODE BS_MODE_QUERY_STAT
#define DEFAULT_RC_MODE SAMPLE_RC_FIXQP
#define DEFAULT_FPS 25
#define DEFAULT_GOP DEFAULT_FPS * 2
#define DEFAULT_IQP DEF_IQP
#define DEFAULT_PQP DEF_PQP
#define DEFAULT_KBITRATE 256
#define DEFAULT_FIRSTQP 34
#define DEFAULT_STAT_TIME 2
#define DEFAULT_AVBR_FRM_LOST_OPEN 1
#define DEFAULT_H264_PROFILE_DEFAULT CVI_H264_PROFILE_DEFAULT

#define CVI_H265_VENC_WIDTH_MIN "352"
#define CVI_H265_VENC_HEIGHT_MIN "288"

#define CVI_H265_VENC_WIDTH_MAX "4096"
#define CVI_H265_VENC_HEIGHT_MAX "2304"

#define CVI_H265_VENC_FRAMERATE_MAX "30"

#define CVI_H264_VENC_WIDTH_MIN "352"
#define CVI_H264_VENC_HEIGHT_MIN "288"

#define CVI_H264_VENC_WIDTH_MAX "4096"
#define CVI_H264_VENC_HEIGHT_MAX "2304"

#define CVI_H264_VENC_FRAMERATE_MAX "30"

#define CVI_H26x_MAX_NUM_ROI 8

#define CVI_H26x_IP_QP_DELTA_DEFAULT 2
#define CVI_H26x_IP_QP_DELTA_MIN -10
#define CVI_H26x_IP_QP_DELTA_MAX 30

/* define reference from middleware cvi_venc.h, need to be removed in future*/
#define CVI_H26x_INITIAL_DELAY_DEFAULT 1000 //CVI_INITIAL_DELAY_DEFAULT

#define CVI_H26x_MAX_I_PROP_DEFAULT CVI_H26X_MAX_I_PROP_DEFAULT
#define CVI_H26x_MAX_I_PROP_MAX 100
#define CVI_H26x_MAX_I_PROP_MIN 0

#define CVI_H264_CHROMA_QP_OFFSET_DEFAULT 0
#define CVI_H265_CB_QP_OFFSET_DEFAULT 0
#define CVI_H265_CR_QP_OFFSET_DEFAULT 0

#define CVI_H26x_MIN_I_PROP_DEFAULT CVI_H26X_MIN_I_PROP_DEFAULT

#define CVI_H26x_THRD_LV_DEFAULT CVI_H26X_THRDLV_DEFAULT
#define CVI_H26x_THRD_LV_MIN CVI_H26X_THRDLV_MIN
#define CVI_H26x_THRD_LV_MAX CVI_H26X_THRDLV_MAX

#define CVI_H264_ENTROPY_MODE_DEFAULT CVI_H264_ENTROPY_DEFAULT
#define CVI_H264_ENTROPY_MODE_MIN 0
#define CVI_H264_ENTROPY_MODE_MAX 1

#define CVI_H26x_CHANGE_POS_DEFAULT 90
#define CVI_H26x_CHANGE_POS_MIN 50
#define CVI_H26x_CHANGE_POS_MAX 100

#define CVI_H26x_MAX_BITRATE_DEFAULT 5000
#define CVI_H26x_MAX_BITRATE_MIN 0
#define CVI_H26x_MAX_BITRATE_MAX 1000000

#define CVI_H26x_MIN_STILL_PERCENT_DEFAULT 10
#define CVI_H26x_MIN_STILL_PERCENT_MIN 5
#define CVI_H26x_MIN_STILL_PERCENT_MAX 100

#define CVI_H26x_MAX_STILL_QP_DEFAULT 48
#define CVI_H26x_MAX_STILL_QP_MIN 0
#define CVI_H26x_MAX_STILL_QP_MAX 51

#define CVI_H26x_MOTION_SENSITIVITY_DEFAULT 80
#define CVI_H26x_MOTION_SENSITIVITY_MIN 0
#define CVI_H26x_MOTION_SENSITIVITY_MAX 256

#define CVI_H26x_AVB_FRM_GAP_DEFAULT 3
#define CVI_H26x_AVB_FRM_GAP_MIN 0
#define CVI_H26x_AVB_FRM_GAP_MAX 100

#define CVI_H26x_AVB_PURE_STILL_THR_DEFAULT 4
#define CVI_H26x_AVB_PURE_STILL_THR_MIN 0
#define CVI_H26x_AVB_PURE_STILL_THR_MAX 100

#define CVI_ROI_RELATIVE_QP false
#define CVI_ROI_ABSOLUTE_QP true
#define CVI_ROI_MAX_QP 51
#define CVI_ROI_MIN_QP -51

#define CVI_JPEG_VENC_WIDTH_MIN "352"
#define CVI_JPEG_VENC_HEIGHT_MIN "288"

#define CVI_JPEG_VENC_WIDTH_MAX "4096"
#define CVI_JPEG_VENC_HEIGHT_MAX "2304"

#define CVI_JPEG_VENC_FRAMERATE_MAX "30"
